package com.atguigu.hbase;

import lombok.Getter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.io.IOException;

public class HbaseConnect {

    @Getter
    static Connection connection = initConnect();

    static Connection initConnect(){
        Configuration configuration = new Configuration();
        configuration.set("hbase.zookeeper.quorum","hadoop102,hadoop103,hadoop104");
        //configuration.set("hbase.zookeeper.property.clientPort","2181");
        configuration.set("hbase.client.ipc.pool.size","10");

        Connection connection = null;
        try {
            connection = ConnectionFactory.createConnection(configuration);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return  connection;
    }


    public static void main(String[] args) throws IOException {

        Configuration configuration = new Configuration();
        configuration.set("hbase.zookeeper.quorum","hadoop102,hadoop103,hadoop104");
        //configuration.set("hbase.zookeeper.property.clientPort","2181");
        configuration.set("hbase.client.ipc.pool.size","10");

        Connection connection = ConnectionFactory.createConnection(configuration);

        System.out.println(connection);

        connection.close();
    }
}
